<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" th:src="@{/js/jquery-1.10.2.js}"></script>
    <script type="text/javascript">
        $(function () {// 初始化内容
            countDown();
        });

        function countDown() {
            var remainSeconds = $("#remainSecond").val();
            var timeout;
            if (remainSeconds > 0) {
                $("#buybutton").attr("disabled", true);
                timeout = setTimeout(function () {
                    $("#remainSecond").val(remainSeconds - 1);
                    countDown();
                }, 1000);
            } else if (remainSeconds == 0) {
                $("#buybutton").attr("disabled", false);
                if (timeout) {

                    clearTimeout(timeout);
                }
            } else {
                $("#buybutton").attr("disabled", true);
            }
            // setInterval()
            //  alert(remainSeconds);
        }
    </script>


</head>
<body>
<h1>Detail</h1>
<div><img th:src="@{'/img/'+${goodsVo.goods_img}}" style="width:200px;height:200px;"/></div>
<div th:text="${goodsVo.goods_name}"></div>
<div th:text="${goodsVo.goods_title}"></div>
<div th:text="${goodsVo.goods_price}"></div>
<div th:text="${goodsVo.goods_stock}"></div>

<div th:text="${goodsVo.seckill_price}"></div>
<div th:text="${goodsVo.stock_count}"></div>
<div th:text="${#dates.format(goodsVo.start_date,'yyyy-MM-dd hh:mm:ss')}"></div>
<div th:text="${#dates.format(goodsVo.end_date,'yyyy-MM-dd hh:mm:ss')}"></div>
<div><input id="remainSecond" type="text" th:value="${remainSeconds}"></div>
<div th:if="${secStatus eq 0}">准备开始 <span th:text="${'剩余：' + remainSeconds +'秒'}"></span></div>
<div th:if="${secStatus eq 1}">开始秒杀</div>
<div th:if="${secStatus eq 2}">秒杀结束</div>
<div>
    <form id="seckillForm" method="post" action="/doSeckill">
        <input name="goodsId" th:value="${goodsVo.id}"/>
        <button type="submit" id="buybutton">立即秒杀</button>
    </form>


</div>
</body>
</html>